Xbasic
Array insert Method
Syntax
V <array>.insert(N position [,N count])
Arguments
- positionNumeric
The index where the first element should be inserted.
- countNumeric
The number of elements to insert.
Description
Insert entries into array, resizing the array if needed.
Discussion
The <array>.insert() method inserts count entries in a single dimensional array starting at position. If necessary, the array is resized to accommodate the additional entries.
Example
Consider the following array:
dim A[4] as C A[1] = "Orange" A[2] = "Banana" A[3] = "Apple" A[4] = "Pineapple"
Suppose we want to insert two values, "Pear" and "Mango", into the array. This could be accomplished as follows:
A.insert(2,2) A[2] = "Pear" A[3] = "Mango" ? A = [1] = "Orange" [2] = "Pear" [3] = "Mango" [4] = "Banana" [5] = "Apple" [6] = "Pineapple"